package com.passion.validator;

import com.passion.exception.ValidationException;

import java.util.function.Predicate;

/**
 * @program offline-e-commerce-data-warehouse
 * @Description 参数校验器
 * @Author limeihua
 * @Date 2024/10/16 16:59
 * @Version 1.0
 */
public class ParameterValidator {

    public static <T> void validate(T parameter, Predicate<T> condition, String errorMessage) throws ValidationException {
        if (!condition.test(parameter)) {
            throw new ValidationException(errorMessage);
        }
    }
}
